package com.server.web.controller.pinggu;

import com.server.common.annotation.Log;
import com.server.common.core.controller.BaseController;
import com.server.common.core.domain.AjaxResult;
import com.server.common.core.page.TableDataInfo;
import com.server.common.enums.BusinessType;
import com.server.common.utils.poi.ExcelUtil;
import com.server.pinggu.domain.SenStreets;
import com.server.pinggu.service.ISenStreetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ltao
 * @date 2022-10-23
 */
@RestController
@RequestMapping("/sen/streets")
public class SenStreetsController extends BaseController
{
    @Autowired
    private ISenStreetsService senStreetsService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SenStreets senStreets)
    {
        List<SenStreets> list = senStreetsService.queryList(senStreets);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SenStreets senStreets)
    {
        List<SenStreets> list = senStreetsService.queryList(senStreets);
        ExcelUtil<SenStreets> util = new ExcelUtil<SenStreets>(SenStreets.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(senStreetsService.getById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SenStreets senStreets)
    {
        return toAjax(senStreetsService.save(senStreets));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SenStreets senStreets)
    {
        return toAjax(senStreetsService.updateById(senStreets));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(senStreetsService.removeByIds(Arrays.asList(ids)));
    }
}
